package com.AAA.service.Impl.mht;

import com.AAA.dao.mht.ITmhtMapper;
import com.AAA.entity.MyPage;
import com.AAA.entity.mht.TMht;
import com.AAA.service.mht.ITmhtService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TmhtServiceImpl implements ITmhtService {
    @Autowired
    private ITmhtMapper mapper;

    @Override
    public boolean addall(TMht tmht) {
        int insert = mapper.insert(tmht);
        if(insert >0){
            return true;
        }
        return false;
    }

    @Override
    public PageInfo query(MyPage myPage, TMht tMht) {
        PageHelper.startPage(myPage.getPage(),myPage.getLimit());
        List<TMht> tMhts = mapper.queryall(tMht);
        PageInfo pageInfo = new PageInfo(tMhts);
        return pageInfo;
    }

    @Override
    public boolean add(TMht tMht) {
        int insert = mapper.insert(tMht);
        if (insert>0){
            return true;
            }
        return false;
    }

    @Override
    public boolean edit(TMht tMht) {
        int i = mapper.updateByPrimaryKeySelective(tMht);
        if (i>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean delete(Integer qid) {
        int i = mapper.deleteByPrimaryKey(qid);

        if (i>0){
            return true;
        }
        return false;
    }

    @Override
    public TMht selectById(Integer qid) {

        return mapper.selectByPrimaryKey(qid);
    }


}
